var _ajax = require('../../utils/ajax');
var _Server = require('../../utils/server');
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        // 设置标题
        that.setData({
            title: options.title
        });
        _ajax.courseList(options.categoryId, '', function(data) {
            if (data.code == 0) {
                var that = this;
                var data = data.data;
                that.setData({
                    courseListData: data,
                    indexUrl: _Server.url
                });
                if (data.length <= 0) {
                    wx.showToast({
                        title: '暂无数据',
                        icon: 'success',
                        duration: 2000
                    })
                }
            }
        }, this);
    },
    fnCourseDetails: function(e) {
        var that = this;
        var articleId = e.currentTarget.dataset.articleid;
        wx.navigateTo({
            url: '../courseDetailsOld/courseDetailsOld?articleId=' + articleId,
        });
    }
})